<?php
namespace app\home\model;
use think\Model;
use think\Db;
use think\Session;
use think\Exception;

class Examresult extends model
{
    protected $error = '';

    /**
     * 返回试卷详细信息
     * @access public
     * @return array
     */
    public function getInfo($id){
        $stuid = Session::get('id');
        $this->error = '';
        if($id){
            $data = Db::table('examresult')
                ->alias('a')
                ->join('student w','a.stuid = w.stuid')
                ->where(['a.paperid'=>$id,'a.stuid'=>$stuid])
                ->field('a.*,w.phone')
                ->find();
        }else{
            $this->error = '参数错误';
        }
        return empty($this->error) ? $data : false;
    }
    /**
     * 获取错误信息
     */
    public function getError(){
        return $this->error;
    }

}
